/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.LinkedList;

/**
 *
 * @author mehlicious
 */
public class Data {
    public class Datum {
        public long milliseconds;
        public int phraseNum;
        public int errors;
        
        public Datum(int pNum, long mSec){
            milliseconds = mSec;
            phraseNum = pNum;
            errors = 0;
        }
    }
    
    public int count;
    public LinkedList<Datum> item;
    
    public Data (){
        item = new LinkedList<Datum>();
        count = 1;
    }
    
    public void addData(long time){
        item.add(new Datum(count, time));
        count ++;
    }
    
    public void addError(){
        if(!item.isEmpty()){
            item.getLast().errors ++;
        }
    }
    
    public String toString(){
        String s = "";
        
        for (Datum d: item){
            s += "Phrase #" + d.phraseNum 
                    + "\tTime: " + d.milliseconds 
                    + "\tErrors: " + d.errors + "\n";
        }
        
        return s;
    }
    
    public String getTabDelimitedData(){
        String s = "";
        
        for (Datum d: item){
            s += d.phraseNum + "\t" + d.milliseconds + "\t" + d.errors + "\n";
        }
        
        return s;
    }
}
